package com.zznj.xzjc.adapter.index;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zznj.xzjc.R;
import com.zznj.xzjc.bean.JddwBean;
import com.zznj.xzjc.utils.StringUtils;

import java.util.List;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/7
 */
public class JdgldwAdapter extends BaseQuickAdapter<JddwBean, BaseViewHolder> {

    public JdgldwAdapter(int layoutResId, @Nullable List<JddwBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, JddwBean item) {
        helper.setText(R.id.titleLabel,"被监督行政单位"+(helper.getLayoutPosition()+1));
        helper.addOnClickListener(R.id.delBtn);
        helper.addOnClickListener(R.id.selectBtn);
        TextView delBtn = helper.getView(R.id.delBtn);
        TextView selectBtn = helper.getView(R.id.selectBtn);

        EditText dwmcTv = helper.getView(R.id.dwmcTv);
        EditText frdbTv = helper.getView(R.id.frdbTv);
        EditText frdbzw = helper.getView(R.id.frdbzw);
        EditText zsdTv = helper.getView(R.id.zsdTv);
        EditText yzbmTv = helper.getView(R.id.yzbmTv);
        EditText lxfsTv = helper.getView(R.id.lxfsTv);
        EditText wtdlrTv = helper.getView(R.id.wtdlrTv);
        EditText wtdlrlxfs = helper.getView(R.id.wtdlrlxfs);
        EditText beizhuTv = helper.getView(R.id.beizhuTv);

        dwmcTv.setText(StringUtils.toString(item.getOrgName()));
        frdbTv.setText(StringUtils.toString(item.getLegalPersonName()));
        frdbzw.setText(StringUtils.toString(item.getLegalPersonDuty()));
        zsdTv.setText(StringUtils.toString(item.getAddress()));
        yzbmTv.setText(StringUtils.toString(item.getPostalCode()));
        lxfsTv.setText(StringUtils.toString(item.getPhoneNumber()));
        wtdlrTv.setText(StringUtils.toString(item.getAgentPersonName()));
        wtdlrlxfs.setText(StringUtils.toString(item.getAgentPhoneNumber()));
        beizhuTv.setText(StringUtils.toString(item.getRemark()));

        dwmcTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setOrgName(s.toString());
            }
        });

        frdbTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setLegalPersonName(s.toString());
            }
        });
        frdbzw.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setLegalPersonDuty(s.toString());
            }
        });


        zsdTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setAddress(s.toString());
            }
        });
        yzbmTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setPostalCode(s.toString());
            }
        });
        lxfsTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setPhoneNumber(s.toString());
            }
        });
        wtdlrTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setAgentPersonName(s.toString());
            }
        });
        wtdlrlxfs.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setAgentPhoneNumber(s.toString());
            }
        });
        beizhuTv.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void afterTextChanged(Editable s) {
                item.setRemark(s.toString());
            }
        });

    }
}
